<!doctype html>  
<html lang="en">  
<head>  
    <meta charset="UTF-8">  
    <title>2</title>  
    <style>  
        *{  
            padding: 0;  
            margin: 0;  
        }  
        ul li{list-style-type: none}  
        #banner{  
            width: 800px;  
            height: 400px;  
            overflow: hidden;  
        }  
        #banner ul{  
            width: 3200px;  
            overflow: hidden;  
        }  
        #banner ul>li{  
            width: 800px;  
            height: 400px;  
            float: left;  
        }  
        img{  
            max-width: 100%;  
        }  
    </style>  
</head>  
<body>  
    <div id="banner">  
        <ul>  
            <li><img src="images/1.png" alt=""></li>  
            <li><img src="images/2.png" alt=""></li>  
            <li><img src="images/3.png" alt=""></li>  
            <li><img src="images/4.png" alt=""></li>  
        </ul>  
    </div>  
    <input type="button" value="left" class="left"/>  
    <input type="button" value="right" class="right"/>  
  
  
    <script src="jquery-1.11.3.min.js"></script>  
    <script>  
        $(function () {  
            $('.left').click(function () {  
                $("#banner ul").animate
                ({marginLeft:"-800px"},600,function () {  
                    $("#banner ul>li").eq(0).appendTo($("#banner ul"));  //被选元素appendTo结尾追加
                    $("#banner ul").css('marginLeft','0px');  
                });  
            })  
            $('.right').click(function () {  
                $("#banner ul").css('marginLeft','-800px');  
                $("#banner ul>li").eq(3).prependTo($("#banner ul")); //被选元素开头插入 prependTo
                $("#banner ul").animate({marginLeft:"0px"},600);  
            })  
        })  
    </script>  
</body>  
</html>  

